#!/usr/bin/env python
#coding=utf-8

from aladin.database import db

class Teacher(db.Model):
    __tablename__ = 'teacher'

    uid             = db.Column(db.Integer, primary_key=True)
    avatar          = db.Column(db.String(255), default='')
    nickname        = db.Column(db.String(32), default='')
    realname        = db.Column(db.String(32), default='')
    gender          = db.Column(db.Integer, default=0)
    birth_year      = db.Column(db.Integer, default=0)
    stature         = db.Column(db.Integer, default=0)
    weight          = db.Column(db.Float, default=0.00)
    city            = db.Column(db.String(32), default='')
    jingdu          = db.Column(db.Float, default=None)
    weidu           = db.Column(db.Float, default=None)
    price           = db.Column(db.Float, default=0.00)
    unit            = db.Column(db.String(16), default='')
    is_cert         = db.Column(db.Integer, default=0)
    cert_time       = db.Column(db.Integer, default=0)
    cert_tags       = db.Column(db.String(255), default='')
    goods_tags_json = db.Column(db.Text, default=None)
    rating_num      = db.Column(db.Integer, default=0)
    rating_count    = db.Column(db.Integer, default=0)
    is_real         = db.Column(db.Integer, default=0)
    like_count      = db.Column(db.Integer, default=0)
    fav_count       = db.Column(db.Integer, default=0)
    order_count     = db.Column(db.Integer, default=0)
    is_display      = db.Column(db.Integer, default=0)
    id_no           = db.Column(db.String(32), default='')
    signature       = db.Column(db.String(255), default='')
    hx_pwd          = db.Column(db.String(32), default='')
    hx_name         = db.Column(db.String(32), default='')

    def __str__(self):
        return "Teacher => { \
uid:%d, avatar:'%s', nickname:'%s', realname:'%s', gender:%d,  \
birth_year:%d, stature:%d, weight:%0.2f, city:'%s', jingdu:%0.2f,  \
weidu:%0.2f, price:%0.2f, unit:'%s', is_cert:%d, cert_time:%d,  \
cert_tags:'%s', goods_tags_json:'%s', rating_num:%d, rating_count:%d, is_real:%d,  \
like_count:%d, fav_count:%d, order_count:%d, is_display:%d, id_no:'%s',  \
signature:'%s', hx_pwd:'%s', hx_name:'%s'}" % (
self.uid, self.avatar, self.nickname, self.realname, self.gender, 
self.birth_year, self.stature, self.weight, self.city, self.jingdu, 
self.weidu, self.price, self.unit, self.is_cert, self.cert_time, 
self.cert_tags, self.goods_tags_json, self.rating_num, self.rating_count, self.is_real, 
self.like_count, self.fav_count, self.order_count, self.is_display, self.id_no, 
self.signature, self.hx_pwd, self.hx_name)

    __repr__ = __str__


class TeacherRegion(db.Model):
    __tablename__ = 'teacher_region'

    id = db.Column(db.Integer, primary_key=True)
    uid = db.Column(db.Integer, default=0)
    region_id = db.Column(db.Integer, default=0)
    region_name = db.Column(db.String(32), default='')

    def __str__(self):
        return "TeacherRegion => { \
id:%d, uid:%d, region_id:%d, region_name:'%s'}" % (
self.id, self.uid, self.region_id, self.region_name)

    __repr__ = __str__


class TeacherGoods(db.Model):
    __tablename__ = 'teacher_goods'

    goods_id    = db.Column(db.Integer, primary_key=True)
    uid         = db.Column(db.Integer, default=0)
    goods_name  = db.Column(db.String(32), default='')
    goods_price = db.Column(db.Float, default=0.00)
    goods_unit  = db.Column(db.String(16), default='hour')
    other_price = db.Column(db.Float, default=0.00)
    other_desc  = db.Column(db.String(32), default='')
    student_num = db.Column(db.Integer, default=0)
    can_day     = db.Column(db.String(16), default='')
    can_time    = db.Column(db.String(64), default='')
    add_time    = db.Column(db.Integer, default=0)
    cat_id      = db.Column(db.Integer, default=0)
    cat_img     = db.Column(db.String(255), default='')

    def __str__(self):
        return "TeacherGoods => { \
goods_id:%d, uid:%d, goods_name:'%s', goods_price:%0.2f, goods_unit:'%s',  \
other_price:%0.2f, other_desc:'%s', student_num:%d, can_day:'%s', can_time:'%s',  \
add_time:%d, cat_id:%d, cat_img:'%s'}" % (
self.goods_id, self.uid, self.goods_name, self.goods_price, self.goods_unit, 
self.other_price, self.other_desc, self.student_num, self.can_day, self.can_time, 
self.add_time, self.cat_id, self.cat_img)

    __repr__ = __str__


class TeacherCat(db.Model):
    __tablename__ = 'teacher_cat'

    id      = db.Column(db.Integer, primary_key=True)
    uid     = db.Column(db.Integer, default=0)
    cat_id  = db.Column(db.Integer, default=0)
    cat_pid = db.Column(db.Integer, default=0)

    def __str__(self):
        return "TeacherCat => { \
id:%d, uid:%d, cat_id:%d, cat_pid:%d}" % (
self.id, self.uid, self.cat_id, self.cat_pid)

    __repr__ = __str__


